import requests

from DataTest.JsonData.read_json import load_json
from DataTest.ANR.path import *

self_token, match_token = load_json(json_data_path)


def end_meeting(meeting_type):
    """
    结束奇遇
    :param meeting_type:奇遇类型：夏日奇遇：meeting_summer，上学奇遇：meeting_school
    :return:结束奇遇
    """
    end_meeting_url = f'http://124.220.33.63:8700/api/v2/meetings/{meeting_type}/end'

    for token in self_token:
        header = {
            'Authorization': f'Bearer {token}',
            'Content-Type': 'application/json',
        }

        end_meeting_res = requests.post(url=end_meeting_url, headers=header)
        # print(end_meeting_res.json())
        if end_meeting_res.status_code == 200:

            print(f'用户{token}结束奇遇成功')

        elif end_meeting_res.status_code == 30037:

            print(f'用户{token}奇遇没在进行中，无法结束')

        else:
            print(f'用户{token}结束奇遇失败或token错误')


if __name__ == '__main__':
    end_meeting('meeting_summer')
